package com.lingyi.algorithm.lab2;

import cn.hutool.core.collection.CollUtil;

import java.util.ArrayList;

/**
 * 头插
 * @author chenweilong
 * @email 1433471850@qq.com
 * @date 2020-08-19 16:53
 */
public class HeadPut {


    public static void main(String[] args) {

        ArrayList<Integer> ints = CollUtil.newArrayList(1, 2, 3, 4, 5, 6);

        Node head = new Node();
        head.setT(-1);

        for (Integer anInt : ints) {
            Node headNext = head.getNext();

            Node newNode = new Node();
            newNode.setT(anInt);
            newNode.setNext(headNext);


            head.setNext(newNode);
        }


        while (head.getNext() != null) {
            head = head.getNext();
            System.out.println(head.getT());
        }



    }
}
